package com.bs.demo.common;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalTime;

@Component
@Slf4j
public class MyMetaObjectMappeer implements MetaObjectHandler {
    /**
     * 插入操作，自动填充
     *
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("公共字段自动填充【insert】。。。");
        metaObject.setValue("Time", LocalTime.now());
        log.info(String.valueOf(LocalTime.now()));
        log.info(String.valueOf(LocalDate.now()));
        metaObject.setValue("Date", LocalDate.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
